package org.crazydog.converter.tests;

import org.crazydog.converter.feet.gui.ConverterFrame;

import junit.framework.Assert;
import junit.framework.TestCase;

public class ConverterFrameTest extends TestCase {

	public void testMainMethod(){
		try{
		String[] test = new String[0];
		ConverterFrame.main(test);
		}
		catch(Exception e){
			Assert.fail(e.getMessage());
		}
	}

	public void testGetJTInput() {
		ConverterFrame frame = new ConverterFrame();
		frame.getJTInput().setText("1");
		
		assertEquals("1", frame.getJTInput().getText());
	}

	public void testGetJTResult() {
		ConverterFrame frame = new ConverterFrame();
		assertEquals("", frame.getJTResult().getText());
	}

	public void testInvailidString() {
		ConverterFrame frame = new ConverterFrame();
		frame.setJTInput("Test");
		frame.calculate();
		assertEquals("", frame.getJTResult().getText());
	}
	
	public void testNegitiveInput(){
		ConverterFrame frame = new ConverterFrame();
		frame.setJTInput("-1");
		frame.calculate();
		assertEquals("", frame.getJTResult().getText());
	}
	
	public void testSpaceString(){
		ConverterFrame frame = new ConverterFrame();
		frame.setJTInput(" 1 2 ");
		frame.calculate();
		assertEquals("3.6576000000000004", frame.getJTResult().getText());
	}
	
	public void testCorrectString(){
		ConverterFrame frame = new ConverterFrame();
		frame.setJTInput("1");
		frame.calculate();
		assertEquals("0.3048", frame.getJTResult().getText());
	}
	
	public void testEmptyString(){
		ConverterFrame frame = new ConverterFrame();
		frame.setJTInput("");
		frame.calculate();
		assertEquals("", frame.getJTResult().getText());
	}
	
	

}
